package com.example.comunicacionactividades;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class Segunda extends Activity {
	
	//private EditText salida;
    private TextView entrada;
	
	/** Called when the activity is first created. */
	@Override 
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.segunda);
        Bundle extras = getIntent().getExtras();
        String name = extras.getString("name");
        entrada =(TextView) findViewById(R.id.etiqueta1_segunda);
        entrada.setText(entrada.getText().toString()+" "+ name+",");
        
        Button b_aceptar =(Button) findViewById(R.id.boton_aceptar);
		b_aceptar.setOnClickListener(new View.OnClickListener(){
	          public void onClick(View view){
	        	  devolverResultado_ok(null);}
	        });
		
		Button b_rechazar =(Button) findViewById(R.id.boton_rechazar);
		b_rechazar.setOnClickListener(new View.OnClickListener(){
	          public void onClick(View view){
	        	  devolverResultado_nok(null);}
	        });
    }
	
	public void devolverResultado_ok(View view){
		Intent intent = new Intent(this, MainActivity.class);
	    intent.putExtra("resultado","ACEPTADO");
	    setResult(Activity.RESULT_OK, intent);
	    finish();
	}
	
	public void devolverResultado_nok(View view){
		Intent intent = new Intent(this, MainActivity.class);
	    intent.putExtra("resultado","RECHAZADO");
	    setResult(Activity.RESULT_CANCELED, intent);
	    finish();
	}

}
